package cn.dubito.seller.task;

import cn.dubito.seller.enums.ChanEnum;
import cn.dubito.seller.service.VerifyService;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author liliang
 * @description:
 * @date 2018/6/2.
 */
@Component
public class VerifyTask {

    @Autowired
    private VerifyService verifyService;

    @Scheduled(cron = "0 0 1,3,5 * * ?")
    public void makeVerificationFile() {
        for (ChanEnum chanEnum: ChanEnum.values()) {
            verifyService.makeVerificationFile(chanEnum.getChanId(), DateUtils.addDays(new Date(),-1));
        }
    }

    @Scheduled(cron = "0 0 2,4,6 * * ?")
    public void verify() {
        for (ChanEnum chanEnum: ChanEnum.values()) {
            verifyService.verifyOrder(chanEnum.getChanId(), DateUtils.addDays(new Date(),-1));
        }
    }
}
